<template>
	<view>
		<image :src="imgSrc" v-if="imgSrc"></image>
		<button @click="captureImage">拍照</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgSrc: ''
			}
		},
		methods: {
			captureImage(e) {
				var cmr = plus.camera.getCamera();
				var res = cmr.supportedImageResolutions[0];
				var fmt = cmr.supportedImageFormats[0];
				console.log("分辨率: " + res + ", 格式: " + fmt);
				cmr.captureImage((path) => {
						this.imgSrc = path;
					},
					(error) => {
						console.log("调用摄像头拍照失败: " + error.message);
					}, {
						resolution: res,
						format: fmt
					}
				);
			}
		}
	}
</script>

<style>

</style>
